package cn.lizemin.fakedata.security;

/**
 * @author lzm
 * @Date 2024/7/7
 * @description
 */
public class SecurityContextHolder {

    // 这个InheritableThreadLocal是所有线程都有一个，还是所有线程都共用这一个，应该是每个线程都有一个
    private static final InheritableThreadLocal<UserDetails> USER_CONTEXT = new InheritableThreadLocal<>();

    public static UserDetails getCurrentUser() {
        return USER_CONTEXT.get();
    }

    public static void setCurrentUser(UserDetails user) {
        USER_CONTEXT.set(user);
    }

    public static void clear() {
        USER_CONTEXT.remove();
    }



}
